qui {
	capture program drop ccn_newsym
	local count=0
	foreach lhs in $LHSlist { 
		local controls="${CONTROLlist_`lhs'}"
		local subsample = "$subsample"
		if "`subsample'"=="non_mom_income" {
			local controls="${CONTROLlist_`lhs'_income}"
	    }
		foreach rhs in $RHSlist { 
			foreach robust in $robust_list {
				forvalues K=$K_list {
					noisily display "LHS=`lhs', RHS=`rhs', SE=`robust', K=`K', $S_DATE, $S_TIME"
					qui {
						local count=`count'+1
						matrix actual_estimates_mat = J(1,36,-9)
						local rowcounter = 1
						local i = 1
						use "$datapath/003_cluster_`subsample'_`lhs'.dta", clear
						local control_length = 0
						foreach control of varlist `controls' {
							local control_length = `control_length' + 1
						}
						global control_length = `control_length'
						qui tab X_`K', generate(dumX_`K'_)

						qui ccn_newsym naiveN_deltatop `K' `rhs' `lhs' robust "`controls'" het_tobit
						qui return list
						qui ccn_newsym naive `K' `rhs' `lhs' robust "`controls'" het_tobit
						qui return list

						qui ccn_newsym naive `K' `rhs' `lhs' `robust' "`controls'" het_tobit
						matrix actual_estimates_mat[`rowcounter',1] = r(BETA)
						matrix actual_estimates_mat[`rowcounter',2] = r(SE)
						matrix actual_estimates_mat[`rowcounter',3] = r(DELTA_top)
						matrix actual_estimates_mat[`rowcounter',4] = r(DELTA_top_SE)
						matrix actual_estimates_mat[`rowcounter',5] = r(SAMP)
						matrix actual_estimates_mat[`rowcounter',6] = r(ESAMP)
						/*
						qui ccn_newsym tobit `K' `rhs' `lhs' `robust' "`controls'" het_tobit
						matrix actual_estimates_mat[`rowcounter',7] = r(BETA)
						matrix actual_estimates_mat[`rowcounter',8] = r(SE)		
						matrix actual_estimates_mat[`rowcounter',9] = r(DELTA)
						matrix actual_estimates_mat[`rowcounter',10] = r(DELTA_SE)
						matrix actual_estimates_mat[`rowcounter',11] = r(DELTA_top)
						matrix actual_estimates_mat[`rowcounter',12] = r(DELTA_top_SE)
						matrix actual_estimates_mat[`rowcounter',13] = r(ESAMP)	
						*/
						qui ccn_newsym het_tobit `K' `rhs' `lhs' `robust' "`controls'" het_tobit
						matrix actual_estimates_mat[`rowcounter',14] = r(BETA)
						matrix actual_estimates_mat[`rowcounter',15] = r(SE)		
						matrix actual_estimates_mat[`rowcounter',16] = r(DELTA)
						matrix actual_estimates_mat[`rowcounter',17] = r(DELTA_SE)
						matrix actual_estimates_mat[`rowcounter',18] = r(DELTA_top)
						matrix actual_estimates_mat[`rowcounter',19] = r(DELTA_top_SE)
						matrix actual_estimates_mat[`rowcounter',20] = r(ESAMP)

						qui ccn_newsym symmetric `K' `rhs' `lhs' `robust' "`controls'" het_tobit
						matrix actual_estimates_mat[`rowcounter',21] = r(BETA)
						matrix actual_estimates_mat[`rowcounter',22] = r(SE)		
						matrix actual_estimates_mat[`rowcounter',23] = r(DELTA)
						matrix actual_estimates_mat[`rowcounter',24] = r(DELTA_SE)
						matrix actual_estimates_mat[`rowcounter',25] = r(DELTA_top)
						matrix actual_estimates_mat[`rowcounter',26] = r(DELTA_top_SE)
						matrix actual_estimates_mat[`rowcounter',27] = r(ESAMP)	

						qui ccn_newsym het_uniform `K' `rhs' `lhs' `robust' "`controls'" het_tobit
						matrix actual_estimates_mat[`rowcounter',28] = r(BETA)
						matrix actual_estimates_mat[`rowcounter',29] = r(SE)		
						matrix actual_estimates_mat[`rowcounter',30] = r(DELTA)
						matrix actual_estimates_mat[`rowcounter',31] = r(DELTA_SE)
						matrix actual_estimates_mat[`rowcounter',32] = r(DELTA_top)
						matrix actual_estimates_mat[`rowcounter',33] = r(DELTA_top_SE)
						matrix actual_estimates_mat[`rowcounter',34] = r(ESAMP)	

						qui ccn_newsym naiveN `K' `rhs' `lhs' `robust' "`controls'" het_tobit
						matrix actual_estimates_mat[`rowcounter',35] = r(BETA)
						matrix actual_estimates_mat[`rowcounter',36] = r(SE)


						local rowcounter = `rowcounter'+1
						local i = `i' + 1
						mat colnames actual_estimates_mat = b_Naive se_Naive dt_Naive se_dt_Naive N Neff_Naive  ///
							b_Tobit se_Tobit d_Tobit se_d_Tobit dt_Tobit se_dt_Tobit Neff_Tobit ///
							b_HetTobit se_HetTobit d_HetTobit se_d_HetTobit dt_HetTobit se_dt_HetTobit Neff_HetTobit ///
							b_HetSymm se_HetSymm d_HetSymm se_d_HetSymm dt_HetSymm se_dt_HetSymm Neff_HetSymm ///
							b_HetUni se_HetUni d_HetUni se_d_HetUni dt_HetUni se_dt_HetUni Neff_HetUni ///
							b_NaiveN se_NaiveN
						clear

						qui svmat actual_estimates_mat, names(col)
						gen LHS="`lhs'"
						gen RHS="`rhs'"
						gen Kcluster=`K'
						gen Robust="`robust'"
						save "$datapath/004_hom_results_`subsample'_`lhs'_`robust'_K`K'.dta", replace
					}
				}
			}
		}			
	}

}
